unit DbConvert;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,

  FormMDIChild,

  cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinFoggy, dxSkinGlassOceans,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  dxSkinPumpkin, dxSkinSeven, dxSkinSharp, dxSkinSilver, dxSkinSpringTime,
  dxSkinStardust, dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
  dxSkinXmas2008Blue, dxSkinscxPCPainter, dxLayoutControl, cxContainer, cxEdit,
  dxLayoutcxEditAdapters, cxTextEdit, Menus, StdCtrls, cxButtons, cxMemo,
  IniFiles, dxSkinOffice2010Black, dxSkinOffice2010Blue,
  dxSkinOffice2010Silver, dxLayoutControlAdapters,
  dxLayoutContainer;

type
  TfmDbConvert = class(TfmMDIChild)
    edUserAdm: TcxTextEdit;
    liUserAdm: TdxLayoutItem;
    edUserAdmPassword: TcxTextEdit;
    liUserAdmPassword: TdxLayoutItem;
    lcWindowGroup4: TdxLayoutGroup;
    edUserRole: TcxTextEdit;
    liUserRole: TdxLayoutItem;
    mmoSQL: TcxMemo;
    lcWindowItem2: TdxLayoutItem;
    cxButton1: TcxButton;
    lcWindowItem4: TdxLayoutItem;
    procedure cxButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  {
    var
    fmDatabaseCreate: TfmDatabaseCreate;
  }

const
  scCreateOptions = 'CREATE OPTIONS';

implementation

uses AppConst, Convert, MainDatamodule;
{$R *.dfm}

procedure TfmDbConvert.cxButton1Click(Sender: TObject);
var
  DbConvertor: TConvertor;
begin
  DbConvertor := TConvertor.Create(Self);
  try
    {
      DbConvertor.SourceFormat := dbFirebird;
      DbConvertor.Source.ConnectionString := //
      'Provider=MSDASQL.1;' + //
      'Persist Security Info=True;' + //
      'User ID=SYSDBA;' + //
      'Password=masterkey;' + //
      'Data Source=Testing;' + //
      'Mode=Read;' + //
      'Extended Properties="DSN=Testing;Driver=Firebird/InterBase(r) driver;Dbname=localhost:C:\Project\Delphi\Testing\Database\Firebird\TESTING.FDB;CHARSET=WIN1251;PWD=masterkey;UID=SYSDBA;"';

      DbConvertor.TargetFormat := dbOracle;
      DbConvertor.Target.ConnectionString := //
      'Provider=OraOLEDB.Oracle;' + //
      'Persist Security Info=True;' + //
      'User ID=TEST_ADM;' + //
      'Password=TEST;' + //
      'Data Source=ORADEV;' + // .sart.must-ipra
      'Extended Properties=""';
    }

    DbConvertor.SourceFormat := dbOracle;
    DbConvertor.SourceSchema := 'TEST_ADM';
    DbConvertor.Source.ConnectionString := //
      'Provider=OraOLEDB.Oracle;' + //
      'Persist Security Info=True;' + //
      'User ID=' + DbConvertor.SourceSchema + ';' + //
      'Password=TEST;' + //
      'Data Source=ORADEV;' + // .sart.must-ipra
      'Extended Properties=""';

    DbConvertor.TargetFormat := dbFirebird;
    DbConvertor.TargetSchema := '';
    DbConvertor.Target.ConnectionString := //
      'Provider=MSDASQL.1;' + //
      'Persist Security Info=True;' + //
      'User ID=SYSDBA;' + //
      'Password=masterkey;' + //
      'Data Source=Testing;' + //
      'Mode=Read;' + //
      'Extended Properties="DSN=Testing;Driver=Firebird/InterBase(r) driver;Dbname=localhost:C:\Project\Delphi\Testing\Database\Firebird\TESTING.FDB;CHARSET=WIN1251;PWD=masterkey;UID=SYSDBA;"';

    mmoSQL.Lines.Text := DbConvertor.CreateAllTables;
  finally
    DbConvertor.Free;
  end;

  (*
    if dmMain.ConnectToDB then
    begin
    s := CreateAllTables(dbtOracle);
    mmoSQL.Lines.Text := s;

    {
    if CreateAllRelations and dmMain.conTarget.InTransaction then
    dmMain.conTarget.CommitTrans;
    }
    end;
  *)
end;

end.
